<?php
namespace app\api\controller;

use app\api\service\LoginService;
use app\api\service\InviteService;
use app\BaseController;
use app\Response;
use think\facade\Request;

class Invite extends BaseController
{
    public function inviteView(){
        if (Request::isPost()) {
            $user_id = LoginService::getUserIdFromToken();
            if (!is_numeric($user_id)) {
                return $user_id;
            }
            $info = InviteService::inviteViewService($user_id);
            return $info;
        }
    }

    public function intviteUserInfoCount(){
        if (Request::isPost()) {
            $user_id = LoginService::getUserIdFromToken();
            if (!is_numeric($user_id)) {
                return $user_id;
            }
            $info = InviteService::intviteInfoCountService($user_id);
            return $info;
        }
    }


    public function intviteUserList(){
        if (Request::isPost()) {
            $user_id = LoginService::getUserIdFromToken();
            if (!is_numeric($user_id)) {
                return $user_id;
            }
            $page = Request::post("page",1);
            $num = Request::post("num",10);
            $type = Request::post("type",23);
            $res = InviteService::intviteUserListService($user_id,$page,$num,$type);
            return $res;
        }
    }


    public function rewardDetailsList(){
        if (Request::isPost()) {
            $user_id = LoginService::getUserIdFromToken();
            if(!is_numeric($user_id)){
                return $user_id;
            }
            $type = Request::param("type",23);//22商家 23达人
            $page = Request::param("page",1);
            $num = Request::param("num",10);
            $res = InviteService::intviteRewardListService($user_id,$page,$num,$type);
            return $res;
        }
    }
}